#ifndef REPORTWIDGET_H
#define REPORTWIDGET_H

#include <QFrame>
#include <QTextEdit>

namespace Ui {
class ReportWidget;
}

class TextAnchor
{
public:
	int pageNumber;
	QPointF normalizedPos;
	QByteArray docHash;
	QString pixmapPath;
};

class ReportWidget : public QFrame
{
	Q_OBJECT
	
public:
	explicit ReportWidget(QWidget *parent = 0);
	~ReportWidget();

	QList<TextAnchor> anchors();

	QTextEdit *getTextEdit();

public slots:
	void setText(QString text);
	bool insertAnchor(int pageNumber, QPointF normalizedPos);
	bool insertInterDocAnchor(QByteArray docHash, int pageNumber, QPointF normalizedPos, QString reference);

signals:
	void snapBottomRequested();
	void snapRightRequested();
	void textChanged(QString text);
	void navigateRequested(int pageNumber, QPointF normalizedPos);
	void navigateRequested(QByteArray docHash, int pageNumber, QPointF normalizedPos);

protected:
	bool eventFilter(QObject *obj, QEvent *event);

	bool decodeAnchor(QString anchor, QByteArray &docHash, int &pageNumber, QPointF &normalizedPos);
	
protected slots:
	void on_btnSnapBottom_toggled(bool checked);
	void on_btnSnapRight_toggled(bool checked);
	void on_textEdit_textChanged();
	void on_btnBold_toggled(bool checked);
	void on_textEdit_currentFontChanged(const QFont &f);
	void on_btnItalic_toggled(bool checked);
	void on_btnUnderline_toggled(bool checked);
	void on_btnStrikethrough_toggled(bool checked);
	void on_btnMonospace_toggled(bool checked);
	void on_btnSubscript_toggled(bool checked);
	void on_btnSuperscript_toggled(bool checked);
	void on_btnPickTextColor_clicked();
	void on_btnClearFormatting_clicked();
	void onAnchorClicked(QString anchor);

private:
	Ui::ReportWidget *ui;
};

#endif // REPORTWIDGET_H
